Skip to content

feat: Add getEnabledAccessibilityServices to AccessibilityInfo (Android) - #57864

Open
ecryptoguru wants to merge 2 commits into
react:mainfrom
ecryptoguru:feat/accessibility-enabled-services
Open

feat: Add getEnabledAccessibilityServices to AccessibilityInfo (Android)#57864
ecryptoguru wants to merge 2 commits into
react:mainfrom
ecryptoguru:feat/accessibility-enabled-services

Conversation

@ecryptoguru

@ecryptoguru ecryptoguru commented Aug 8, 2026

Copy link
Copy Markdown

Summary

Add a new AccessibilityInfo.getEnabledAccessibilityServices(feedbackTypeFlags?) method that returns the list of currently enabled accessibility service IDs on Android. This uses Android's AccessibilityManager.getEnabledAccessibilityServiceList() under the hood.

Closes #30862

Motivation

As described in issue #30862, it is useful to query what accessibility services a user has currently enabled. This allows apps to tailor their UI to the specific service — for example, disabling video autoplay when a screen reader service is active, since the audio would interrupt screen reader announcements.

The existing isScreenReaderEnabled() method only detects Talkback specifically. This new method provides a general-purpose way to get all enabled accessibility services.

Changes

  • JS API (AccessibilityInfo.js): Added getEnabledAccessibilityServices(feedbackTypeFlags: number = -1): Promise<Array<string>>. On Android, calls the native module; on other platforms, resolves to an empty array.
  • Android native (AccessibilityInfoModule.kt): Implemented getEnabledAccessibilityServices() using accessibilityManager.getEnabledAccessibilityServiceList(feedbackTypeFlags), returning service IDs via WritableNativeArray.
  • Flow spec (NativeAccessibilityInfo.js): Added optional getEnabledAccessibilityServices method to the TurboModule spec.
  • TypeScript (AccessibilityInfo.d.ts): Added type declaration with @platform android JSDoc.
  • Generated types (ReactNativeApi.d.ts): Regenerated via yarn build-types.
  • Jest mock (jest-preset/jest/mocks/AccessibilityInfo.js): Added mock for getEnabledAccessibilityServices.
  • Tests (AccessibilityInfo-test.js): Added 4 test cases covering Android success, feedback type flags passthrough, native unavailability error, and iOS empty array.
  • Typetests (index.tsx): Added type usage test.

API

AccessibilityInfo.getEnabledAccessibilityServices(feedbackTypeFlags?: number): Promise<string[]>
  • feedbackTypeFlags: Optional Android AccessibilityServiceInfo.FEEDBACK_* flags bitmask. Defaults to -1 (all feedback types).
  • Returns: Promise resolving to an array of enabled accessibility service IDs (from AccessibilityServiceInfo.getId()).

Test plan

  • Jest unit tests pass (yarn jest AccessibilityInfo-test.js) — 42/42 tests pass
  • ESLint passes on all modified JS files
  • TypeScript type tests pass (no new errors)
  • yarn build-types regenerates ReactNativeApi.d.ts correctly
  • Android integration test on device/emulator (requires Android toolchain)

Changelog:

[Android] [Added] - Add getEnabledAccessibilityServices method to AccessibilityInfo to query enabled accessibility service IDs

Generated with Devin

Add a new `AccessibilityInfo.getEnabledAccessibilityServices()` method
that returns the list of currently enabled accessibility service IDs
on Android, using `AccessibilityManager.getEnabledAccessibilityServiceList()`.

This addresses the need to query which accessibility services a user
has enabled, allowing apps to tailor their UI accordingly (e.g.,
disabling video autoplay when a screen reader service is active).

Changes:
- Add `getEnabledAccessibilityServices(feedbackTypeFlags?)` to the
  JS AccessibilityInfo API (returns Promise<Array<string>>)
- Implement native Android module method in AccessibilityInfoModule.kt
- Add optional method to NativeAccessibilityInfo Flow spec
- Update TypeScript definitions (.d.ts) and generated ReactNativeApi.d.ts
- Update Jest mock and add comprehensive unit tests
- Add typetest coverage

Closes react#30862

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@meta-cla

meta-cla Bot commented Aug 8, 2026

Copy link
Copy Markdown

Hi @ecryptoguru!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 8, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: Enabled services

1 participant